package com.example.chessbattleplatform.web.chess_rooms.CopyUtils;


import com.example.chessbattleplatform.web.Sys_User.Pojo.mapper.User;
import com.example.chessbattleplatform.web.chess_rooms.Pojo.Vo.RoomUserData;
import com.example.chessbattleplatform.web.chess_rooms.Pojo.Vo.RoomsDataVo;
import com.example.chessbattleplatform.web.chess_rooms.Pojo.Vo.RoomsVo;
import com.example.chessbattleplatform.web.chess_rooms.Pojo.dto.RoomsDto;
import com.example.chessbattleplatform.web.chess_rooms.Pojo.mappers.RoomMember;
import com.example.chessbattleplatform.web.chess_rooms.Pojo.mappers.Rooms;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;


@Mapper(componentModel = "spring")
public abstract class CopyRoomsMapper {

    @Mappings({
            @Mapping(target = "roomCode", source = "roomsDto.name"),
            @Mapping(target = "roomUuid", source = "roomUuid"),
            @Mapping(target = "roomType", source = "roomsDto.type"),
            @Mapping(target = "roomStatus", constant = "WAITING"),
            @Mapping(target = "roomPassword", source = "roomsDto.password")
    })
    // 数据接收类（房间） 转为 数据库类
    public abstract Rooms RoomsDtoToRooms(RoomsDto roomsDto, String roomUuid);


    @Mappings({
            @Mapping(target = "roomUuid", source = "roomUuid"),
            @Mapping(target = "userId", source = "user.id"),
            @Mapping(target = "userName", source = "user.userName"),
            @Mapping(target = "avatar", source = "user.avatar"),

            @Mapping(target = "playerStatus", constant = "WAITING")
    })
    // 数据接收类（用户） 转为 数据库类
    public abstract RoomMember createToRoomMember(String roomUuid, User user);


    public abstract List<RoomUserData> listRoomMemberToRoomUserData(List<RoomMember> roomMembers);

    @Mappings({
            @Mapping(target = "userImages", source = "avatar"),
            @Mapping(target = "userStatus", source = "memberType"),
            @Mapping(target = "awaitStatusEnum", source = "playerStatus")
    })
    public abstract RoomUserData RoomMemberToRoomUserData(RoomMember roomMember);

    // 列表 数据库类 转 列表 数据显示类
    public abstract List<RoomsVo> listToRoomMemberToRoomsLimitVo(List<Rooms> rooms);

    @Mappings({
            @Mapping(target = "roomName", source = "roomCode"),
    })
    // 数据库类 转 数据显示类
    public abstract RoomsVo RoomMemberToRoomsLimitVo(Rooms rooms);


    @Mappings({
            @Mapping(target = "roomName",source = "roomCode"),
    })
    //   Rooms类型 转 RoomsDataVo 类型：
    public abstract RoomsDataVo RoomsToRoomsDataVo(Rooms rooms);
}
